#include "Comparator.h"
#include <iostream>

using namespace std;

Comparator::Comparator(bool (*smaller) (char*, char*), bool (*smallerOE) (char*, char*), bool (*greater) (char*, char*), bool (*greaterOE) (char*, char*), bool (*equal) (char*, char*))
{
    this->smaller   = smaller;
    this->smallerOE = smallerOE;
    this->greater   = greater;
    this->greaterOE = greaterOE;
    this->equal     = equal;
}

Comparator::Comparator(const Comparator& other)
{
    this->smaller   = other.smaller;
    this->smallerOE = other.smallerOE;
    this->greater   = other.greater;
    this->greaterOE = other.greaterOE;
    this->equal     = other.equal;
}

bool Comparator::operator()(CompType type, char* one, char* other)
{
    switch (type)
    {
    case SMALLER:
        return smaller(one, other);
    case SMALLEROREQUAL:
        return smallerOE(one, other);
    case GREATER:
        return greater(one, other);
    case GREATEROREQUAL:
        return greaterOE(one, other);
    case EQUAL:
        return equal(one, other);
    }
    return false;   //wont ever happen...hopefully ^^
}
